{% load static %}
<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>DTU列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/xadmin.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/js/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="/static/js/jquery.cookie.js"></script>
    <script src="/static/js/flow-meter.js" charset="utf-8"></script>
    <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>

<body>
<div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">权限管理</a>
        <a><cite>角色列表</cite></a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
    </a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">

                    </form>
                </div>
                <div class="layui-card-body ">
                    <table lay-filter="role" id="role">
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/html" id="toolbarDemo">

</script>
<script>
    layui.use(['table', 'form', 'jquery', 'element', 'tree'],
        function () {
            $ = layui.jquery;
            table = layui.table;
            form = layui.form;

            table.render({
                elem: '#role', //指定原始表格元素选择器（推荐id选择器）
                cols: [[
                    {
                        numbbers: true,
                        width: '5%',
                        title: '序号',
                        templet: function (data) {
                            return data.LAY_TABLE_INDEX + 1;
                        }
                    },
                    {field: 'label', title: '角色名', edit: 'text',},
                    {
                        field: '',
                        title: '拥有的权限',
                        templet: function (d) {
                            return "<button class=\"layui-btn\" onclick=\"xadmin." +
                                "open('权限列表','/role/auth/view/?name=" + d['name'] + "')\">查看</button>";
                        }
                    },
                    {field: 'remark', title: '备注', edit: 'text',},
                ]],
                url: '/handler/auth/?action=query_role',
                page: true,
                toolbar: '#toolbarDemo',
                defaultToolbar: [],
            });
            //监听单元格编辑
            table.on('edit(role)',
                function (obj) {
                    let data = obj.data;
                    post({
                        "param": JSON.stringify(data),
                        "action": "edit_role"
                    }, '/handler/auth/', function (data) {
                        if (!data.success) {
                            layer.msg(data.msg, {icon: 5, time: 2000});
                        }
                    });
                });
        });
</script>
<script>var _hmt = _hmt || [];
(function () {

})();</script>

</html>